package com.xci.sys.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xci.core.domain.BaseEntity;
import com.xci.core.helper.DateHelper;
import com.xci.core.internal.Const;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 系统安全用户
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "系统用户")
public class SysSecurityUser extends BaseEntity {
    /**
     * 用户主键
     */
    @ApiModelProperty(value = "用户主键")
    private String id;

    /**
     * 用户姓名
     */
    @ApiModelProperty(value = "用户姓名")
    private String name;

    /**
     * 账号
     */
    @ApiModelProperty(value = "账号")
    private String account;

    /**
     * 角色主键
     */
    @ApiModelProperty(value = "角色主键")
    private String roleId;

    /**
     * 机构主键
     */
    @ApiModelProperty(value = "机构主键")
    private String deptId;

    /**
     * 是否超管 [是_1,否_0]
     */
    @ApiModelProperty(value = "是否超管 [是_1,否_0]")
    private Boolean isAdmin;

    /**
     * 密码
     */
    @ApiModelProperty(hidden = true)
    private String password;

    /**
     * 密码盐
     */
    @ApiModelProperty(hidden = true)
    private String pwdSalt;

    /**
     * 必须修改密码 [必须_1,非必须_0]
     */
    @ApiModelProperty(hidden = true)
    private Boolean pwdMustModify;

    /**
     * 不允许修改密码 [不允许_1,允许_0]
     */
    @ApiModelProperty(value = "不允许修改密码 [不允许_1,允许_0]")
    private Boolean pwdNotAllowedModify;

    /**
     * 密码永不过期 [永不过期_1,过期_0]
     */
    @ApiModelProperty(value = "密码永不过期 [永不过期_1,过期_0]")
    private Boolean pwdNeverExpire;

    /**
     * 密码过期时间
     */
    @ApiModelProperty(value = "密码过期时间")
    private Date pwdExpireTime;

    /**
     * 有效期开始时间
     */
    @ApiModelProperty(value = "有效期开始时间")
    private Date allowStartTime;

    /**
     * 有效期结束时间
     */
    @ApiModelProperty(value = "有效期结束时间")
    private Date allowEndTime;

    /**
     * 是否过期
     */
    @ApiModelProperty(value = "是否过期")
    public Boolean getIsExpire() {
        return DateHelper.isExpired(new Date(),allowStartTime,allowEndTime);
    }

    /**
     * 启用状态 [启用_1,禁用_0]
     */
    @ApiModelProperty(value = "启用状态 [启用_1,禁用_0]")
    private Boolean status;
}